home *** CD-ROM | disk | FTP | other *** search
- # testing item position calculation
-
-
- proc indexToY {w n} {
- # calculate the Y co-ord for an index in the list
- $w getValues \
- -height h -itemCount count \
- -visibleItemCount vis \
- -topItemPosition top
-
- set item_height [expr {$h / $vis}]
- set vis_index [expr {$n - $top + 1}]
-
- set y [expr {((2*$vis_index -1) * $item_height) / 2}]
- return $y
- }
-
- proc buttonPress {w n} {
- # simulate a button press
- return [$w callActionProc ListBeginSelect() \
- -type ButtonPress \
- -x 0 -y [indexToY $w $n]]
- }
-
- proc buttonRelease {w n} {
- # simulate a button release
- return [$w callActionProc ListEndSelect() \
- -type ButtonRelease \
- -x 0 -y [indexToY $w $n]]
- }
-
- xtAppInitialize -class Program
-
- xmScrolledList .list managed \
- -items "a b c d e f g h i j" \
- -itemCount 10 \
- -selectionPolicy single_select \
- -visibleItemCount 5 \
- -topItemPosition 3
- .list singleSelectionCallback {puts stdout %item}
-
- .list getValues -height h
- puts stdout "height: $h"
-
- set n 7
- puts stdout "Pressing button $n"
- buttonPress .list $n
- buttonRelease .list $n
-
-
- . realizeWidget
-
- . mainLoop
-